<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
    <base href="<%=basePath%>">
    <title></title>
    <meta http-equiv="cache-control" content="no-cache">
    <link rel="stylesheet" type="text/css" href="css/maintable.css" >

    <script type="text/javascript" src="js/jquery-1.8.0.js"></script>
    <script>
        $(function (){
            // 全选按钮联动
            $("#ch_checkall,#top_ch_checkall").click(function (){
                $("input[name=ck_id]").attr("checked",this.checked);
            });


        });

        function show(pageIndex){
            window.location.href="GoodsServlet?flag=seeHistory&pageIndex="+pageIndex;
        }
    </script>

</head>

<body>
    <div class ="div_title">
        <div class="div_titlename"> <img src="/images/san_jiao.gif" ><span>历史信息</span></div>
        <div class="div_titleoper">
            <input type="checkbox" id="top_ch_checkall"/> 全选  <a href="javascript:deleteChecked()"><img src="/images/del.gif"/>删除</a> </div>
    </div>

    <form action="xxx"  name="form1">
        <input name="flag" value="deleteChecked" type="hidden">

        <table class="main_table" >
            <tr>
                <th><input type="checkbox" id="ch_checkall" /></th>	<th>商品名</th> 	<th>历史变更内容</th> 	<th>修改日期</th> 	<th>操作</th>
            </tr>
            <c:forEach items="${goodsList}" var="g">
                <tr>
                    <td>
                        <input type="checkbox" name="ck_id" value="${g.id}" id="id"/>
                    </td>
                    <td>${g.goodsName}</td>
                    <td> <a title="${g.historyChange}">${g.shortHs}</a> </td>
                    <td>
                        <fmt:timeZone value="GMT">
                            <fmt:formatDate value="${g.editDate}" pattern="yyyy-MM-dd HH:mm"/>
                        </fmt:timeZone>
                    </td>
                    <td>
                        <a href="GoodsServlet?flag=seeNowVersion&id=${g.goodsId}&historyId=${g.historyId}">查看详情</a>
                    </td>
                </tr>

            </c:forEach>
        </table>
    </form>

    <div class="div_page" >
        <div class="div_page_left">    共有 <label>${page.rowCount}</label> 条记录，当前第 <label>${page.pageIndex}</label> 页，共 <label>${page.pageCount}</label> 页	</div>
        <div class="div_page_right" >

            <c:choose>
                <c:when test="${page.hasPre }">
                    <button onclick="show(1)"> 首页</button>
                    <button onclick="show(${page.pageIndex-1})"> 上一页</button>
                </c:when>
                <c:otherwise>
                    首页
                    上一页
                </c:otherwise>
            </c:choose>

            <c:choose>
                <c:when test="${page.hasNext }">
                    <button onclick="show(${page.pageIndex+1})">  下一页 </button>
                    <button onclick="show(${page.pageCount})"> 尾页</button>
                </c:when>
                <c:otherwise>
                    下一页
                    尾页
                </c:otherwise>
            </c:choose>


            <button onclick="show(document.getElementById('pageIndex').value)">转到</button>
            <input type="text" name="pageIndex" id="pageIndex" value="${page.pageIndex }" /> 页

        </div>

    </div>
</body>
</html>